Comparing DSEM Analyses in Mplus and Stan: A Case Study Across Four Ecological Momentary Assessment Datasets

SAA 2025

Jean-Paul Snijder

RWTH Aachen

Andreas B. Neubauer

RWTH Aachen

Introduction

Software availability for Dynamic Structural Equation Models

  • Mplus
    • Main software package
    • Fast, support, existing model syntax
    • Limitations
    • “Black Box”
  • Stan
    • Free, Open source
    • Limitations
    • Complex, little literature

How does Stan compare to Mplus?

  • Little peer-reviewed evidence (DSEM in Stan)
  • Mostly on simulated data
    • No missing data
    • No strange human patterns







Compare Parameter Recovery of DSEMs in Mplus vs. Stan

with various model structures and messy data

Study Selection

Four models with openly available data:

  1. Daily dairy: Effect of Missingness
  2. ESM: Dichotomous time-varying predictor
  3. Daily dairy: Large sample, many parameters
  4. ESM: Dummy dichotomous/categorical variables

Study Selection

Four models with openly available data:

  1. Daily dairy: Effect of Missingness
  2. ESM: Dichotomous time-varying predictor

Neubauer et al., 2022: Effect of Missing Data

Model 2 (within):

In this study there were 5 variables that are measured once per day for 21 days, and there different cross/auto-regressive effects with random slopes.

Missingness

Model 2 Comparison

Convergence

Model N Rhat Time
Mplus Clean 100 <1.01 3 min.
Mplus Full 108 <1.01 3 min.
Stan Clean 100 <1.01 21 min.
Stan Full 108 <1.01

Convergence

Model N Rhat Time
Mplus Clean 100 <1.01 3 min.
Mplus Full 108 <1.01 3 min.
Stan Clean 100 <1.01 21 min.
Stan Full 108 <1.01 263 min.

Bolzenkötter et al., 2025: Dichotomous Variable

Model 1 (within)

  • \(RU^w_{t}\) = Rumination (distressing, repetitive thinking)
  • \(NA^w_{t}\) = Negative Affect (e.g., sadness, anxiety)
  • \(RU^w_{t-1}\), \(NA^w_{t-1}\) = Autoregressive effects
  • \(\beta_{MIRU}\), \(\beta_{MINA}\) = Effects of mindfulness on RU and NA at the same time point

Model 1 (within)

Like Mplus, the dichotomous variable mi (Mindfulness Intervention) is modeled using a latent probit link:

  • Each mi[i, t] is linked to a latent continuous variable mi_latent[i, t]

      mi_latent[i,t] ~ normal(gamma[3] + u[i,3], 1);
    
    // Observed mi: Bernoulli with probit link
    for (k in 1:N_obs_mi) { ...
      mi[i,t] ~ bernoulli(Phi(mi_latent[i,t]));
    }

Missingness

Model 1 Comparison

Sampler Variability

Conclusion

Take-away message

  • DSEM in Stan works well if missing data is within “normal” range
  • Further tweaking on modeling real data dichotomous/categorical variables
  • Is it worth switching to/learning Stan?
  • I am looking forward to work with mlts
    • promising
    • under development







Thank you for listening

Resources

snijder@psych.rwth-aachen.de

jpsnijder.com

this presentation, stan models, and htmls to get started:

How does this Stan model handle the dichotomous variable?

Like Mplus, the dichotomous variable mi (Mindfulness Intervention) is modeled using a latent probit link:

  • Each mi[i, t] is linked to a latent continuous variable mi_latent[i, t]:

    // Latent probit: underlying normal for each mi
      mi_latent[i,t] ~ normal(gamma[3] + u[i,3], 1);
    
    // Observed mi: Bernoulli with probit link
    for (k in 1:N_obs_mi) {
      int i = ii_obs_mi[k,1];
      int t = ii_obs_mi[k,2];
      mi[i,t] ~ bernoulli(Phi(mi_latent[i,t]));
    }

Handling Missingness in mi:

  • When mi is missing, the model “plugs in” the expected probability from the latent variable, which has a multilevel component, and hence each subject has their own expected probability based on the observed mi.